<?php TPL::output('m/header_meta.tpl.htm'); ?>
    <!--搜索-->
<style>
    .gztj_tab .tabs {
        width: 33%;
    }
    .tj_mim span{
        line-height: 15px;
    }
     html,body{
         overflow:hidden;
         overflow-y:auto;
    }
    /*.adds{word-wrap:break-word;}*/
</style>
<div class="searchbox">
    <form id="search_form" action="m/search/" method="post">
        <header>
            <h1><img src="<?php echo G_STATIC_URL; ?>/mobile/images/logo.png"></h1>
            <span class="search" style="background: #f9f9f9;">
            <input name="q" type="text" id="index_search" placeholder="搜索" style="width:90%;font: 400 13.3333px Arial;text-indent: 5px;float: left;">
            <b onClick="$('#search_form').submit();" style='float: right;width: 15px;line-height: 27px;'>
                <img src="<?php echo G_STATIC_URL; ?>/mobile/images/search.png">
            </b>
            </span>
            <a href="m/inbox/"><em><img src="<?php echo G_STATIC_URL; ?>/mobile/images/note.png"><i id=""><?php echo $this->user_info['inbox_unread'] + $this->user_info['notification_unread']; ?></i></em></a>
        </header>
    </form>
</div>
<!--搜索end-->
<!--分类-->
<div id="wrapper" class="clearfix">
<div class="scroll qumuen">
    <?php if ($this->content_nav_menu) { ?>
        <?php foreach ($this->content_nav_menu as $key => $val) { ?>
            <?php if ($val['title']) { ?>
                <dl class="navs <?php if($_GET['category'] && $_GET['category']==$val['type_id']){echo 'cur';} ?>" cid="<?php echo $val['type_id']; ?>"
                    type="<?php echo $val['type_id']; ?>">
                    <?php if(get_setting('category_display_mode')!='list'){ ?>
                    <dt><a href="javascript:;"><img
                                    src="<?php if($val['icon']){ echo get_setting('upload_url'); ?>/nav_menu/<?php echo $val['icon']; ?><?php } else { ?><?php echo G_STATIC_URL; ?>/css/<?php echo $this->template_name; ?>/img/default_class_imgs.png<?php } ?>"/></a>
                    </dt>
                    <?php } ?>
                    <dd <?php if(get_setting('category_display_mode')=='list'){ ?>style="margin-top: 15px;"<?php } ?>>
                        <a href="javascript:;"><?php echo $val['title']; ?></a>
                    </dd>
                </dl>
            <?php } ?>
        <?php } ?>
    <?php } ?>
</div>
</div>
<!--分类end-->
<!--关注推荐-->
<div class="gztj_tab phb_tab">
    <ul>
        <li class=" tabs" type="is_focus"><a href="#">关注推荐</a></li>
        <li class="cur tabs" type="is_new"><a href="#">最新</a></li>
        <li class="tabs" type="is_hot"><a href="#">热门</a></li>
    </ul>
</div>
<!--关注推荐end-->
<div class="adds" style="padding-bottom: 60px;word-wrap:break-word;word-break:break-all; ">
    <div class="tj_list">
        <ul>
        </ul>
    </div>
</div>

<div id="hots" style="display: none;">
    <input type="hidden" class="hotPage" value="1">
    <div class="phb_two">
        <a val="30"  href="#">30天</a>
        <a val="7" class="cur" href="#">7天</a>
        <a val="1" href="#">当天</a>
    </div>
    <div id="hotList" class="tj_list border_none">
        <ul></ul>
    </div>
</div>
<article class="qmeun">
    <span><img src="<?php echo G_STATIC_URL; ?>/mobile/images/edit.png"></span>
    <a href="m/addarticle/" class="q2" style="display: none;"><img src="<?php echo G_STATIC_URL; ?>/mobile/images/e2.png"></a>
    <a href="m/publish/" class="q3" style="display: none;"><img src="<?php echo G_STATIC_URL; ?>/mobile/images/e3.png"></a>
</article>
<div class="load_more" style="display: none;"><a href="#"><img src="<?php echo base_url();?>/static/mobile/images/loading.gif"></a></div>
<script type="text/javascript">
    jQuery(function ($) {
        var Scroll = new iScroll('wrapper',{hScrollbar:false, vScrollbar:false, vScroll: false});
    });
    var CATEGORY_ID;
    var TYPE;
    var IS_SSL = "is_new";
    var isLoading = false;
    $(function () {
        /*加载分享最新数据*/
        <?php if($_GET['category']){ ?>
            CATEGORY_ID = <?php echo $_GET['category']; ?>;
        <?php }else{ ?>
            CATEGORY_ID = $(".four_class").find('dl.cur').attr('cid') || 0;
        <?php } ?>
        TYPE = $(".four_class dl.cur").attr('type');
        var page = 1;
        var data = {
            category_id: CATEGORY_ID,
            type: TYPE,
            page: page,
            is_ssl: IS_SSL
        };
        AWS.load_index_view(G_BASE_URL + '/m/ajax/get_index_data/', data);

        scroll(function (direction) {
            if (direction == 'down') {
                $(window).scroll(function () {
                    if( $(document).scrollTop() >= 195)
                    {
                        $("div.gztj_tab").addClass('p_fix');
                    }

                    if( $(document).scrollTop() < 195)
                    {
                        $("div.gztj_tab").removeClass('p_fix');
                    }
                    if ($(document).scrollTop()>= ($(document).height() - $(window).height())&&!isLoading) {
                        isLoading = true
                        if (IS_SSL == "is_hot") {
                            AWS.loadIndexHotData();
                        }else{
                            data.page += 1;
                            AWS.load_index_view(G_BASE_URL + '/m/ajax/get_index_data/', data, 1)
                        }
                    }
                });
            }
        });
        <?php if(is_mobile()){ ?>
            var winHeight = $(window).height();   //获取当前页面高度
            $(window).resize(function(){
            var thisHeight=$(this).height();
            if(winHeight - thisHeight >50){
                //当软键盘弹出，在这里面操作
                $('.qmeun,.nav').hide()
            }else{
                //当软键盘收起，在此处操作
                $('.qmeun,.nav').show()
            }
        });
        <?php } ?>

        $(".tabs").each(function (i) {
            $(this).on('touchstart', function (i) {
                isLoading = false;
                if ($(this).hasClass("cur")) {
                    return;
                }
                IS_SSL = $(this).attr('type');
                data.category_id = CATEGORY_ID;
                data.type = TYPE;
                data.page = page;
                data.is_ssl = IS_SSL;
                $("li.tabs").removeClass("cur");
                $(this).addClass('cur');
                if (IS_SSL == 'is_focus') {
                    $("#hots").hide();
                    $(".adds ul").html('')
                    $(".adds").show();

                    window.setTimeout(function () {
                        AWS.load_user_qu_view(G_BASE_URL + '/m/ajax/get_user_qu/', 1);
                    }, 100);
                }
                if (IS_SSL == "is_new") {
                    $(".adds").show();
                    $(".adds ul").html('')
                    $("#hots").hide();
                    AWS.load_index_view(G_BASE_URL + '/m/ajax/get_index_data/', data);
                }
                if (IS_SSL == "is_hot") {
                    $("#hots").show();
                    $(".adds").hide();
                    AWS.loadIndexHotData();
                } else {
                    $("#hots").hide();
                    // $(".adds").hide();
                    $("#hots .hotPage").val(1);
                }
            })
        });
        $(".navs").each(function (i) {
            $(this).on('touchstart', function (i) {
                isLoading = false;
                $(".adds").show();
                $("div.gztj_tab").find('li.cur').removeClass('cur');
                $("div.gztj_tab").find('li').eq(1).addClass('cur');
                CATEGORY_ID = $(this).attr('cid');
                TYPE = $(this).attr('type');
                IS_SSL= $("div.gztj_tab").find('li.cur').attr('type');
                data.category_id = CATEGORY_ID;
                data.type = TYPE;
                data.page = page;
                data.is_ssl = IS_SSL;
                $("dl.navs").removeClass("cur");
                $(this).addClass('cur');
                $("#hots").hide();
                $("#hots .hotPage").val(1);
                $(".phb_two a").removeClass("cur").eq(1).addClass("cur");
                $(".adds ul").html('')
                AWS.load_index_view(G_BASE_URL + '/m/ajax/get_index_data/', data);
            })
        });

        $(document).on('click', '.change_pepole', function () {
            $(this).attr('page', parseInt($(this).attr('page')) + 1);
            AWS.load_user_qu_view(G_BASE_URL + '/m/ajax/get_user_qu/', $(this).attr('page'), 1);
        });

        $(document).on('click', '.like_peo>dl>dd.num_two>a', function () {
            if (G_USER_ID) {
                AWS.User.follow($(this), 'user', $(this).attr('uid'),'<?php echo new_post_hash();?>');
            } else {
                alert('请先登录');
                window.location.href = "/?/m/login/url-";
            }
        });

        $(".phb_two a").click(function () {
            $(this).addClass("cur").siblings().removeClass("cur");
            $("#hots .hotPage").val(1);
            AWS.loadIndexHotData();
        })
    });

    function scroll(fn) {
        var beforeScrollTop = document.body.scrollTop
        window.addEventListener("scroll", function () {
            var afterScrollTop = $(document).scrollTop(),
                delta = afterScrollTop - beforeScrollTop;
            if (delta === 0) return false;
            fn(delta > 0 ? "down" : "up");
            beforeScrollTop = afterScrollTop;
        });
    }
</script>
<?php TPL::output('m/footer.tpl.htm'); ?>